home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / compress / arj_992a.lzh / CRC_CODE.S < prev    next >
Text File  |  1994-08-06  |  1KB  |  57 lines

  1. ;
  2. ; ARJ CRC function
  3. ; Size optimized
  4. ; (c) 1993 Mr Ni! (the Great) of the TOS-crew
  5. ;
  6. ; ulong crc_buf(char *str, ulong len)
  7. ;
  8. ; CALL:
  9. ; D0 = #bytes (long)
  10. ; A0 = buffer
  11. ;
  12. ; Return:
  13. ; D0 = CRC-code
  14. ;
  15. ; uses 1kB buffer on stack
  16. ;
  17. crc_buf:
  18.      move.l  d3,-(sp)
  19.      move.l  d0,-(sp)
  20.      lea     (sp),a1
  21.      lea     -1024(sp),sp
  22.      moveq   #0,d0
  23.      subq.b  #1,d0
  24.      move.l  #$EDB88320,d2
  25. .loop_0:
  26.      moveq   #7,d3
  27.      move.l  d0,d1
  28. .loop_1:
  29.      lsr.l   #1,d1
  30.      bcc.s   .next
  31.      eor.l   d2,d1
  32. .next:
  33.      dbra    d3,.loop_1
  34.      move.l  d1,-(a1)
  35.      dbra    d0,.loop_0
  36.      move.l  1024(sp),d0
  37.      moveq   #-1,d1
  38. .crc_loop:
  39.      moveq   #0,d2
  40.      move.b  (a0)+,d2
  41.      eor.b   d1,d2
  42.      lsr.l   #8,d1
  43.      lsl.w   #2,d2
  44.      move.l  0(a1,d2.w),d2
  45.      eor.l   d2,d1
  46.      subq.l  #1,d0
  47.      bne.s   .crc_loop
  48.      lea     1028(sp),sp
  49.      not.l   d1
  50.      move.l  d1,d0
  51.      move.l  (sp)+,d3
  52.      rts
  53.  
  54. ;d0,d1,d2,d3,d4,d5,d6,d7,a0,a1,a2,a3,a4,a5,a6,a7,sp
  55. *******************************************************************************
  56.  
  57.      END